package ui20131001.helper
{
	import utils.DeviceParser;

	/**
	 * 存放单个设备的公用方法，假设这些方法会被多个地方调用
	 * @author limin
	 * 
	 */	
	public class DeviceTools
	{
		[Bindable]
		[Embed(source='../../assets/assets.swf', symbol='manIcon')]
		public static var manIcon:Class;
		
		[Embed(source='../../assets/assets.swf', symbol='carIcon')]
		public static var carIcon:Class;
		
		[Embed(source='../../assets/assets.swf', symbol='dogIcon')]
		public static var dogIcon:Class;
		
		[Embed(source='../../assets/assets.swf', symbol='homeIcon')]
		public static var homeIcon:Class;
		
		/** 根据类型得到图标 */
		public static function getIconClassByData(display_id:int):Class
		{
			var clz:Class;
			switch(display_id)
			{
				case 1:
					clz = carIcon;
					break;
				case 2:
					clz = manIcon;
					break;
				case 3:
					clz = dogIcon;
					break;
				case 4:
					clz = homeIcon;
					break;
				default:
					manIcon;
			} 
			return clz;
		}
		
		/** 昵称(nickname) */
		public static function getNickName(obj:Object):String
		{
			return obj&&obj.nickname ? obj.nickname : '';
		}
		
		/** 返回机码 */
		public static function getSN(obj:Object):String
		{
			return obj ? obj.sn : '';
		}
		
		/** 得到时间字符表示 */
		public static function getTime(positionData:Object):String
		{
			return Global.getTimeStrByTime(positionData.dateline, true);
		}
		
		/** 得到方向字符表示 */
		public static function getDirectionStr(positionData:Object):String
		{
			var parser:DeviceParser = new DeviceParser(positionData);
			return parser.getDirection();
		}
		
		/** 得到时速字符表示 */
		public static function getSpeedStr(positionData:Object):String
		{
			var parser:DeviceParser = new DeviceParser(positionData);
			return parser.getSpeed();
		}
		
		/** 得到经度字符表示 */
		public static function getLngStr(positionData:Object):String
		{
			var parser:DeviceParser = new DeviceParser(positionData);
			return parser.getLng();
		}
		
		/** 得到纬度字符表示 */
		public static function getLatStr(positionData:Object):String
		{
			var parser:DeviceParser = new DeviceParser(positionData);
			return parser.getLat();
		}
		
		/** 得到ACC字符表示 */
		public static function getAccStr(positionData:Object):String
		{
			var parser:DeviceParser = new DeviceParser(positionData);
			return parser.getAccState();
		}
		
	}
}